package server1;

import lombok.SneakyThrows;
import org.zjx.core.ClusterConfig;
import org.zjx.core.ConfigBasedClusterConfig;
import org.zjx.core.SocketConfig;
import org.zjx.server.SocketServer;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Map;

public class MasterServer  {
    @SneakyThrows
    public static void main(String[] args) {
        ClusterConfig clusterConfig = new ConfigBasedClusterConfig(   new InetSocketAddress(
                "location",
                8888
        ),
                Map.of("USER_QUERY",
                        new InetSocketAddress(
                                InetAddress.getByAddress(new byte[]{127, 0, 0, 1}),
                                8899
                        )
                )
        );

        SocketConfig socketConfig = new SocketConfig();
        socketConfig.setServerHost("127.0.0.1");
        socketConfig.setPort(8888);

        SocketServer master = new SocketServer(socketConfig,clusterConfig);

        master.registerHandler(new LocalTestHandler());
        new Thread(master::start).start();
    }
}
